package com.weita.lightfood.model.dao;


import com.weita.lightfood.model.entity.Order;
import com.weita.lightfood.model.query.order.GenerateOrderQuery;
import com.weita.lightfood.model.query.order.RefundOrderQuery;
import com.weita.lightfood.model.vo.order.OrderVo;
import com.weita.lightfood.model.vo.order.RefundOrderVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author IT_Monster at 2019/03/27 23:08.
 */
@Mapper
@Repository
public interface OrderDao {
    //已接单0、配送中1、已送达2 申请取消订单3、退款成功4、退款失败5

    /**
     * 用户下单 --> 0
     * @param generateOrderQuery
     * @throws Exception
     */
    void generateOrder(GenerateOrderQuery generateOrderQuery) throws Exception;

    /**
     * 用户申请取消订单  -->  3
     * @param refundOrderQuery
     * @throws Exception
     */
    void cancelOrder(RefundOrderQuery refundOrderQuery) throws Exception;

    /**
     * 通过订单号获取订单
     * @param orderId
     * @return
     * @throws Exception
     */
    Order getOrderById(int orderId) throws Exception;

    /**
     * 获取指定用户待评价订单
     * @param userID
     * @return
     * @throws Exception
     */
    List<OrderVo> getDPJOrder(int userID) throws Exception;

    /**
     * 查询指定用户退款申请订单
     * @param userID
     * @return
     * @throws Exception
     */
    List<OrderVo> getSQTKOrder(int userID) throws Exception;

    /**
     * 查询指定用户退款订单
     * @param userID
     * @return
     * @throws Exception
     */
    List<OrderVo> getTKOrder(int userID) throws Exception;

    /**
     * 获取指定用户所有订单
     * @param userID
     * @return
     * @throws Exception
     */
    List<OrderVo> getAll(int userID) throws Exception;

    /**
     * 更改订单状态
     * @param state
     * @param orderId
     * @throws Exception
     */
    void changeOrderState(@Param("state") int state, @Param("orderId") int orderId) throws Exception;

    /**
     * 商家获取所有已接单订单
     * @return
     * @throws Exception
     */
    List<Order> getReceivingOrder() throws Exception;

    /**
     * 商家获取退款申请订单
     * @return
     * @throws Exception
     */
    List<RefundOrderVo> getAllTKSQOrder() throws Exception;

    /**
     * 商家获取已完成订单467
     * @return
     * @throws Exception
     */
    List<Order> getAllCGOrder() throws Exception;

    /**
     * 通过订单id删除订单
     * @param orderId
     * @throws Exception
     */
    void deleteById(int orderId) throws Exception;

    /**
     * 通过订单号获取用户id
     * @param orderId
     * @return
     * @throws Exception
     */
    int getUserIdByOrderId(@Param("orderId") int orderId) throws Exception;

    /**
     * 通过订单号获取地址id
     * @param orderId
     * @return
     * @throws Exception
     */
    int getAddressIdByOrderId(int orderId) throws Exception;

    /**
     * 通过订单号获取菜谱id
     * @param orderId
     * @return
     * @throws Exception
     */
    int getDishIdByOrderId(int orderId) throws Exception;

    /**
     * 通过退款订单号获取退款理由
     * @param orderId
     * @return
     * @throws Exception
     */
    String getReasonByOrderId(int orderId) throws Exception;

    /**
     * 申请取消订单
     * @param refundOrderQuery
     * @throws Exception
     */
    void applicationForDrawback(RefundOrderQuery refundOrderQuery) throws Exception;

    /**
     * 根据年月获取订单获取
     * @param yearMonth
     * @return
     * @throws Exception
     */
    List<Order> getMonthOrders(@Param("yearMonth") String yearMonth) throws Exception;

}
